﻿using baroIstatistik.Class;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace baroIstatistik
{
    public partial class cocukekle : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

               

                List<cocuk2> coc = new List<cocuk2>();


                SqlConnection sqlcon = connection.baglanti;

                SqlCommand sqlcmd = new SqlCommand("select cocukID,adi,yasi,egitim from cocuk where basvuruID=@id", sqlcon);
                sqlcmd.Parameters.AddWithValue("@id", Request.QueryString["basID"].ToString());

                sqlcon.Open();

                SqlDataReader sdr = sqlcmd.ExecuteReader();
                while (sdr.Read())
                {
                    cocuk2 c = new cocuk2();
                    c.CocukID = Convert.ToInt32(sdr["cocukID"]);
                    c.Adi = sdr["adi"].ToString();
                    
                    c.Yasi = sdr["yasi"].ToString();
                    c.Egitim = sdr["egitim"].ToString();


                    coc.Add(c);
                }

                sqlcon.Close();

   Repeater1.DataSource = coc;
   Repeater1.DataBind();

            }
            catch (Exception)
            {


            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                 HttpCookie cok = Request.Cookies["uyebilgileri"];
                cocuk2 c = new cocuk2();
                c.BasvuruID = Convert.ToInt32(Request.QueryString["basID"]);
                c.Adi = cocukadi.Text;
               
                c.Yasi = Cocukyasi.Text;
                c.Egitim = OgrenimDurumu.Text;
                c.UserID = Convert.ToInt32(cok.Values["userid"]);
                c.Baglamadurumu = 2;
                c.kaydet();

                Response.Redirect("cocukekle.aspx?basID=" + Request.QueryString["basID"].ToString());
            }
            catch (Exception)
            {


            }


        }



    }
}